package cn.liulin.java8.selfFunc;

import com.alibaba.fastjson.JSON;

/**
 * cn.liulin.java8.selfFunc$
 *
 * @author ll
 * @date 2023-02-15 17:01:53
 **/
public class FunctionRun {
    public static void main(String[] args) {
        String s = "((true or false) or (true and false)) and true";
        String s3 = s.replaceAll("\\(", "( ").replaceAll("\\)", " )").replaceAll("\\s+", " ");
        String[] s1 = s3.split(" ");
        CalcuFunc calcuFunc = new CalcuFunc();
        for (String s2 : s1) {
            if (s2.equals("(")) {
                calcuFunc.next = new CalcuFunc();
                calcuFunc.next.before = calcuFunc;
                calcuFunc = calcuFunc.next;
            } else if (s2.equals(")")) {
                boolean check = calcuFunc.check();
                calcuFunc = calcuFunc.before;
                calcuFunc.list.add(String.valueOf(check));
            } else {
                calcuFunc.list.add(s2);
            }
        }
        boolean check = calcuFunc.check();
        System.out.println(check);
    }
}
